diff options
author | Sopot Cela | 2016-09-26 10:16:25 +0000 |
---|---|---|
committer | Dani Megert | 2016-09-26 10:30:36 +0000 |
commit | 5bcb7ac5045743f9ec17895a9a12318dd90ea4cb (patch) | |
tree | ea2d98cee208a040d2ee43fef458d3775a5dc90d | |
parent | 8871738e5b595e7715499161b04980d9f16df820 (diff) | |
download | eclipse.platform.text-5bcb7ac5045743f9ec17895a9a12318dd90ea4cb.tar.gz eclipse.platform.text-5bcb7ac5045743f9ec17895a9a12318dd90ea4cb.tar.xz eclipse.platform.text-5bcb7ac5045743f9ec17895a9a12318dd90ea4cb.zip |
Bug 497871 - Generic and extensible text editor
This change creates a new extensible text editor, with extension points
for:
* contentAssist
* hover
* syntax highlighting
Some unit tests show examples of extensions. You can load an IDE with
the suggested change (including org.eclipse.ui.editors.tests) and get a
syntax highlighter, a hover support and some content assist on the plain
text editor.
Bug: 497871
Bug: 496117
Bug: 496115
Bug: 496300
Signed-off-by: Mickael Istria <mistria@redhat.com>
Signed-off-by: Sopot Cela <scela@redhat.com>
Change-Id: I2eec71e4620364aa11c500ec07e54c693863cf44
43 files changed, 2524 insertions, 5 deletions
diff --git a/org.eclipse.ui.genericeditor.tests/.classpath b/org.eclipse.ui.genericeditor.tests/.classpath new file mode 100644 index 00000000000..22f30643cba --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/org.eclipse.ui.genericeditor.tests/.project b/org.eclipse.ui.genericeditor.tests/.project new file mode 100644 index 00000000000..434c0fce422 --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.ui.genericeditor.tests</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> diff --git a/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.core.resources.prefs b/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..99f26c0203a --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 00000000000..5a0ad22d2a7 --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\n diff --git a/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..fae2809a8bb --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,422 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.builder.cleanOutputFolder=clean +org.eclipse.jdt.core.builder.duplicateResourceTask=warning +org.eclipse.jdt.core.builder.invalidClasspath=abort +org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore +org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch +org.eclipse.jdt.core.circularClasspath=error +org.eclipse.jdt.core.classpath.exclusionPatterns=enabled +org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled +org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes=f +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=fg +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=info +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=error +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=error +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=error +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private +org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=info +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=enabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=all_standard_tags +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=error +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=error +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error +org.eclipse.jdt.core.compiler.problem.potentialNullReference=info +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=info +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=info +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=info +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedImport=error +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=info +org.eclipse.jdt.core.compiler.problem.unusedParameter=warning +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=48 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=1 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=false +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=false +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=100 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=false +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=200 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=true +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=true +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=3 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.incompatibleJDKLevel=ignore +org.eclipse.jdt.core.incompleteClasspath=error +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000000..b73bfac6f0d --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +formatter_profile=_JDT UI Code Style Conventions +formatter_settings_version=12 +org.eclipse.jdt.ui.exception.name=e +org.eclipse.jdt.ui.gettersetter.use.is=true +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=java;javax;sun;com;org;org.apache;org.w3c;org.eclipse;org.eclipse.swt;org.eclipse.core;org.eclipse.core.runtime;org.eclipse.core.resources;org.eclipse.core.filebuffers;org.eclipse.text;org.eclipse.jface;org.eclipse.jface.text;org.eclipse.ui;org.eclipse.ui.workbench.texteditor;org.eclipse.ui.texteditor;org.eclipse.ui.editors;org.eclipse.compare;org.eclipse.debug;org.eclipse.debug.ui;org.eclipse.search;org.eclipse.search2;org.eclipse.ltk;org.eclipse.jdt.core;org.eclipse.jdt.internal;org.eclipse.jdt.launching;org.eclipse.jdt.ui;org.eclipse.jdt.internal.ui; +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=99 +org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.staticondemandthreshold=99 diff --git a/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.m2e.core.prefs b/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000000..f897a7f1cb2 --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.pde.prefs b/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.pde.prefs new file mode 100644 index 00000000000..0dd5de3710c --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/.settings/org.eclipse.pde.prefs @@ -0,0 +1,33 @@ +compilers.f.unresolved-features=1 +compilers.f.unresolved-plugins=1 +compilers.incompatible-environment=0 +compilers.p.build=1 +compilers.p.build.bin.includes=1 +compilers.p.build.encodings=2 +compilers.p.build.java.compiler=2 +compilers.p.build.java.compliance=1 +compilers.p.build.missing.output=2 +compilers.p.build.output.library=1 +compilers.p.build.source.library=1 +compilers.p.build.src.includes=1 +compilers.p.deprecated=1 +compilers.p.discouraged-class=1 +compilers.p.internal=1 +compilers.p.missing-packages=0 +compilers.p.missing-version-export-package=2 +compilers.p.missing-version-import-package=2 +compilers.p.missing-version-require-bundle=2 +compilers.p.no-required-att=0 +compilers.p.not-externalized-att=2 +compilers.p.unknown-attribute=0 +compilers.p.unknown-class=0 +compilers.p.unknown-element=0 +compilers.p.unknown-identifier=0 +compilers.p.unknown-resource=0 +compilers.p.unresolved-ex-points=0 +compilers.p.unresolved-import=0 +compilers.s.create-docs=false +compilers.s.doc-folder=doc +compilers.s.open-tags=1 +compilers.use-project=true +eclipse.preferences.version=1 diff --git a/org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF b/org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..5c987c53e4e --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF @@ -0,0 +1,21 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %Plugin.name +Bundle-SymbolicName: org.eclipse.ui.genericeditor.tests;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: %Plugin.providerName +Bundle-Localization: plugin +Export-Package: org.eclipse.ui.genericeditor.tests, + org.eclipse.ui.genericeditor.tests.contributions +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)", + org.junit;bundle-version="4.12.0", + org.eclipse.jface;bundle-version="[3.5.0,4.0.0)", + org.eclipse.text;bundle-version="[3.5.0,4.0.0)", + org.eclipse.ui.genericeditor, + org.eclipse.core.resources;bundle-version="3.11.0", + org.eclipse.jface.text;bundle-version="3.11.0", + org.eclipse.ui;bundle-version="3.108.0", + org.eclipse.ui.workbench.texteditor;bundle-version="3.10.0", + org.eclipse.ui.ide;bundle-version="3.11.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy diff --git a/org.eclipse.ui.genericeditor.tests/about.html b/org.eclipse.ui.genericeditor.tests/about.html new file mode 100644 index 00000000000..8e788d9461d --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/about.html @@ -0,0 +1,28 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> +<title>About</title> +</head> +<body lang="EN-US"> +<h2>About This Content</h2> + +<p>June 2, 2006</p> +<h3>License</h3> + +<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. +For purposes of the EPL, "Program" will mean the Content.</p> + +<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p> + +</body> +</html>
\ No newline at end of file diff --git a/org.eclipse.ui.genericeditor.tests/build.properties b/org.eclipse.ui.genericeditor.tests/build.properties new file mode 100644 index 00000000000..c98d8e12ee9 --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/build.properties @@ -0,0 +1,21 @@ +############################################################################### +# Copyright (c) 2000, 2014 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +# Mickael Istria (Red Hat Inc.) - 419531 Get rid of nested jars +############################################################################### +bin.includes = plugin.properties,\ + test.xml,\ + about.html,\ + .,\ + META-INF/,\ + plugin.xml + +src.includes = about.html + +source.. = src/ diff --git a/org.eclipse.ui.genericeditor.tests/plugin.properties b/org.eclipse.ui.genericeditor.tests/plugin.properties new file mode 100644 index 00000000000..e0525f967c1 --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/plugin.properties @@ -0,0 +1,13 @@ +############################################################################### +# Copyright (c) 2016 Red Hat Inc. and others +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Mickael Istria (Red Hat Inc.) - initial API and implementation +############################################################################### + +Plugin.name= Generic Editor Test Plug-in +Plugin.providerName= Eclipse.org diff --git a/org.eclipse.ui.genericeditor.tests/plugin.xml b/org.eclipse.ui.genericeditor.tests/plugin.xml new file mode 100644 index 00000000000..89178329739 --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/plugin.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.ui.genericeditor.contentAssistProcessors"> + <contentAssistProcessor + class="org.eclipse.ui.genericeditor.tests.contributions.BarContentAssistProcessor" + contentType="org.eclipse.core.runtime.text"> + </contentAssistProcessor> + </extension> + <extension + point="org.eclipse.ui.genericeditor.hoverProviders"> + <hoverProvider + class="org.eclipse.ui.genericeditor.tests.contributions.MagicHoverProvider" + contentType="org.eclipse.core.runtime.text"> + </hoverProvider> + </extension> + <extension + point="org.eclipse.ui.genericeditor.presentationReconcilers"> + <presentationReconciler + class="org.eclipse.ui.genericeditor.tests.contributions.ThePresentationReconciler" + contentType="org.eclipse.core.runtime.text"> + </presentationReconciler> + </extension> + +</plugin> diff --git a/org.eclipse.ui.genericeditor.tests/pom.xml b/org.eclipse.ui.genericeditor.tests/pom.xml new file mode 100644 index 00000000000..d3d52c0c838 --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/pom.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2012, 2015 Eclipse Foundation and others. + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Distribution License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/org/documents/edl-v10.php + + Contributors: + Igor Fedorenko - initial implementation +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>tests-pom</artifactId> + <groupId>eclipse.platform.text</groupId> + <version>4.7.0-SNAPSHOT</version> + <relativePath>../tests-pom/</relativePath> + </parent> + <groupId>org.eclipse.ui</groupId> + <artifactId>org.eclipse.ui.genericeditor.tests</artifactId> + <version>1.0.0-SNAPSHOT</version> + <packaging>eclipse-test-plugin</packaging> + <properties> + <testSuite>${project.artifactId}</testSuite> + <testClass>org.eclipse.ui.genericeditor.tests.GenericEditorTestSuite</testClass> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-surefire-plugin</artifactId> + <version>${tycho.version}</version> + <configuration> + <useUIHarness>true</useUIHarness> + <useUIThread>true</useUIThread> + <dependencies> + <dependency> + <!-- workaround for missing dependency in org.eclipse.e4.ui.services: https://bugs.eclipse.org/462862 --> + <type>eclipse-plugin</type> + <artifactId>org.eclipse.equinox.event</artifactId> + <version>0.0.0</version> + </dependency> + </dependencies> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/CompletionTest.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/CompletionTest.java new file mode 100644 index 00000000000..8f7e69a6d1f --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/CompletionTest.java @@ -0,0 +1,106 @@ +/******************************************************************************* + * Copyright (c) 2016 Red Hat Inc. and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Mickael Istria, Sopot Cela (Red Hat Inc.) + *******************************************************************************/ +package org.eclipse.ui.genericeditor.tests; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Widget; + +import org.eclipse.jface.text.contentassist.ICompletionProposal; + +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.FileEditorInput; + +import org.eclipse.ui.texteditor.AbstractTextEditor; +import org.eclipse.ui.texteditor.ContentAssistAction; +import org.eclipse.ui.texteditor.ITextEditorActionConstants; + +/** + * @since 3.11 + * + */ +public class CompletionTest { + + private AbstractTextEditor editor; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + GenericEditorTestUtils.setUpBeforeClass(); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + GenericEditorTestUtils.tearDownAfterClass(); + } + + @Before + public void setUp() throws Exception { + GenericEditorTestUtils.closeIntro(); + editor = (AbstractTextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getActivePage().openEditor(new FileEditorInput(GenericEditorTestUtils.getFile()), "org.eclipse.ui.genericeditor.GenericEditor"); + } + + @After + public void tearDown() throws Exception { + editor.getSite().getPage().closeEditor(editor, false); + editor= null; + } + + @Test + public void testCompletion() throws Exception { + Set<Shell> beforeShell = new HashSet<>(Arrays.asList(Display.getDefault().getShells())); + editor.selectAndReveal(3, 0); + ContentAssistAction action = (ContentAssistAction) editor.getAction(ITextEditorActionConstants.CONTENT_ASSIST); + action.update(); + action.run(); + Set<Shell> afterShell = new HashSet<>(Arrays.asList(Display.getDefault().getShells())); + afterShell.removeAll(beforeShell); + assertEquals("No completion", 1, afterShell.size()); + Shell completionShell= afterShell.iterator().next(); + Table completionProposalList = findCompletionSelectionControl(completionShell); + assertEquals(1, completionProposalList.getItemCount()); + TableItem completionProposalItem = completionProposalList.getItem(0); + assertEquals("s are good for a beer.", ((ICompletionProposal)completionProposalItem.getData()).getDisplayString()); + // TODO find a way to actually trigger completion and verify result against Editor content + // Assert.assertEquals("Completion didn't complete", "bars are good for a beer.", ((StyledText)editor.getAdapter(Control.class)).getText()); + completionShell.close(); + } + + private Table findCompletionSelectionControl(Widget control) { + if (control instanceof Table) { + return (Table)control; + } else if (control instanceof Composite) { + for (Widget child : ((Composite)control).getChildren()) { + Table res = findCompletionSelectionControl(child); + if (res != null) { + return res; + } + } + } + return null; + } + +} diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/GenericEditorTestSuite.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/GenericEditorTestSuite.java new file mode 100644 index 00000000000..9e41f7e300c --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/GenericEditorTestSuite.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2000, 2016 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Mickael Istria (Red Hat Inc.) - [484157] Add zoom test + *******************************************************************************/ +package org.eclipse.ui.genericeditor.tests; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Test Suite for org.eclipse.ui.editors. + * + * @since 3.0 + */ +@RunWith(Suite.class) +@SuiteClasses({ + CompletionTest.class, + StylingTest.class, + HoverTest.class +}) +public class GenericEditorTestSuite { + // see @SuiteClasses +} diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/GenericEditorTestUtils.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/GenericEditorTestUtils.java new file mode 100644 index 00000000000..33caf13be52 --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/GenericEditorTestUtils.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2016 Red Hat Inc. and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sopot Cela (Red Hat Inc.) + *******************************************************************************/ +package org.eclipse.ui.genericeditor.tests; + +import java.io.ByteArrayInputStream; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; + +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.intro.IIntroPart; + +public class GenericEditorTestUtils { + + private static IProject project; + private static IFile file; + + public static void setUpBeforeClass() throws Exception { + project = ResourcesPlugin.getWorkspace().getRoot().getProject("genericEditorTest"); + project.create(null); + project.open(null); + file = project.getFile("foo.txt"); + file.create(new ByteArrayInputStream("bar 'bar'".getBytes()), true, null); + } + + public static void tearDownAfterClass() throws Exception { + file.delete(true, null); + project.delete(true, null); + } + + public static void closeIntro() { + IIntroPart intro = PlatformUI.getWorkbench().getIntroManager().getIntro(); + if (intro != null) { + PlatformUI.getWorkbench().getIntroManager().closeIntro(intro); + } + } + + public static IFile getFile(){ + return file; + } + +} diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java new file mode 100644 index 00000000000..37f4f1b092f --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2016 Red Hat Inc. and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Mickael Istria, Sopot Cela (Red Hat Inc.) + *******************************************************************************/ +package org.eclipse.ui.genericeditor.tests; + +import static org.junit.Assert.assertEquals; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; + +import org.eclipse.jface.text.AbstractHoverInformationControlManager; +import org.eclipse.jface.text.AbstractInformationControlManager; +import org.eclipse.jface.text.ITextViewer; +import org.eclipse.jface.text.TextViewer; + +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.FileEditorInput; + +import org.eclipse.ui.texteditor.AbstractTextEditor; + +/** + * @since 3.11 + * + */ +public class HoverTest { + + private AbstractTextEditor editor; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + GenericEditorTestUtils.setUpBeforeClass(); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + GenericEditorTestUtils.tearDownAfterClass(); + } + + @Before + public void setUp() throws Exception { + GenericEditorTestUtils.closeIntro(); + editor = (AbstractTextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getActivePage().openEditor(new FileEditorInput(GenericEditorTestUtils.getFile()), "org.eclipse.ui.genericeditor.GenericEditor"); + } + + @After + public void tearDown() throws Exception { + editor.getSite().getPage().closeEditor(editor, false); + editor= null; + } + + @Test + public void testHover() throws Exception { + this.editor.selectAndReveal(2, 0); + // Events need to be processed for hover listener to work correctly + long timeout = 1000; + long start = System.currentTimeMillis(); + while (start + timeout > System.currentTimeMillis()) { + Display.getDefault().readAndDispatch(); + } + // sending event to trigger hover computation + StyledText editorTextWidget = (StyledText) this.editor.getAdapter(Control.class); + editorTextWidget.getShell().forceActive(); + editorTextWidget.getShell().setActive(); + editorTextWidget.getShell().setFocus(); + editorTextWidget.getShell().getDisplay().wake(); + Event hoverEvent = new Event(); + hoverEvent.widget = editorTextWidget; + hoverEvent.type = SWT.MouseHover; + hoverEvent.x = editorTextWidget.getClientArea().x + 5; + hoverEvent.y = editorTextWidget.getClientArea().y + 5; + hoverEvent.display = editorTextWidget.getDisplay(); + hoverEvent.doit = true; + editorTextWidget.notifyListeners(SWT.MouseHover, hoverEvent); + // retrieving hover content + Method getSourceViewerMethod= AbstractTextEditor.class.getDeclaredMethod("getSourceViewer"); + getSourceViewerMethod.setAccessible(true); + ITextViewer viewer = (ITextViewer) getSourceViewerMethod.invoke(editor); + Field textHoverManagerField= TextViewer.class.getDeclaredField("fTextHoverManager"); + textHoverManagerField.setAccessible(true); + AbstractHoverInformationControlManager hover = (AbstractHoverInformationControlManager) textHoverManagerField.get(viewer); + Field informationField = AbstractInformationControlManager.class.getDeclaredField("fInformation"); + informationField.setAccessible(true); + Object hoverData = informationField.get(hover); + Thread.sleep(500); // hoverData populated asynchronously + assertEquals("Alrighty!", hoverData); + } + +} diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/StylingTest.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/StylingTest.java new file mode 100644 index 00000000000..4a5fa8b93ad --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/StylingTest.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2016 Red Hat Inc. and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sopot Cela (Red Hat Inc.) + *******************************************************************************/ +package org.eclipse.ui.genericeditor.tests; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.eclipse.swt.custom.StyleRange; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Control; + +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.FileEditorInput; + +import org.eclipse.ui.texteditor.AbstractTextEditor; + +public class StylingTest { + + private AbstractTextEditor editor; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + GenericEditorTestUtils.setUpBeforeClass(); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + GenericEditorTestUtils.tearDownAfterClass(); + } + + @Before + public void setUp() throws Exception { + GenericEditorTestUtils.closeIntro(); + + editor = (AbstractTextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getActivePage().openEditor(new FileEditorInput(GenericEditorTestUtils.getFile()), "org.eclipse.ui.genericeditor.GenericEditor"); + } + + @After + public void tearDown() throws Exception { + editor.getSite().getPage().closeEditor(editor, false); + editor= null; + } + + @Test + public void testStyle() throws Exception { + + editor.selectAndReveal(4, 8); + StyledText widget = (StyledText) editor.getAdapter(Control.class); + StyleRange style= widget.getStyleRangeAtOffset(4);//get the style of first token + boolean isRed= style.foreground.getRGB().equals(new RGB(255, 0, 0));//is it Red? + Assert.assertTrue("Token is not of expected color", isRed); + } + +} diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/BarContentAssistProcessor.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/BarContentAssistProcessor.java new file mode 100644 index 00000000000..4d5f12ba448 --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/BarContentAssistProcessor.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2016 Red Hat Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * - Mickael Istria (Red Hat Inc.) + *******************************************************************************/ +package org.eclipse.ui.genericeditor.tests.contributions; + +import org.eclipse.jface.text.ITextViewer; +import org.eclipse.jface.text.contentassist.CompletionProposal; +import org.eclipse.jface.text.contentassist.ICompletionProposal; +import org.eclipse.jface.text.contentassist.IContentAssistProcessor; +import org.eclipse.jface.text.contentassist.IContextInformation; +import org.eclipse.jface.text.contentassist.IContextInformationValidator; + +public class BarContentAssistProcessor implements IContentAssistProcessor { + + @Override + public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { + String text = viewer.getTextWidget().getText(); + if (text.length() >= 3 && text.substring(offset - 3, offset).equals("bar")) { + String message = "s are good for a beer."; + CompletionProposal proposal = new CompletionProposal(message, offset, 0, message.length()); + return new ICompletionProposal[] { proposal }; + } + return new ICompletionProposal[0]; + } + + @Override + public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { + return null; + } + + @Override + public char[] getCompletionProposalAutoActivationCharacters() { + return null; + } + + @Override + public char[] getContextInformationAutoActivationCharacters() { + return null; + } + + @Override + public String getErrorMessage() { + return null; + } + + @Override + public IContextInformationValidator getContextInformationValidator() { + return null; + } + +} diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/MagicHoverProvider.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/MagicHoverProvider.java new file mode 100644 index 00000000000..d8f83117ea0 --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/MagicHoverProvider.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2016 Red Hat Inc. and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Mickael Istria (Red Hat Inc.) + *******************************************************************************/ +package org.eclipse.ui.genericeditor.tests.contributions; + +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.ITextHover; +import org.eclipse.jface.text.ITextHoverExtension2; +import org.eclipse.jface.text.ITextViewer; +import org.eclipse.jface.text.Region; + +public class MagicHoverProvider implements ITextHover,ITextHoverExtension2 { + + @Deprecated + @Override + public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { + return null; + } + + @Override + public IRegion getHoverRegion(ITextViewer textViewer, int offset) { + return new Region(0, textViewer.getTextWidget().getText().length()); + } + + @Override + public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { + return "Alrighty!"; + } + +} diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconciler.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconciler.java new file mode 100644 index 00000000000..c7968f845d7 --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/ThePresentationReconciler.java @@ -0,0 +1,28 @@ +package org.eclipse.ui.genericeditor.tests.contributions; + +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.TextAttribute; +import org.eclipse.jface.text.presentation.PresentationReconciler; +import org.eclipse.jface.text.rules.DefaultDamagerRepairer; +import org.eclipse.jface.text.rules.IRule; +import org.eclipse.jface.text.rules.RuleBasedScanner; +import org.eclipse.jface.text.rules.SingleLineRule; +import org.eclipse.jface.text.rules.Token; + +public class ThePresentationReconciler extends PresentationReconciler { + + public ThePresentationReconciler() { + RuleBasedScanner scanner= new RuleBasedScanner(); + IRule[] rules = new IRule[1]; + rules[0]= new SingleLineRule("'", "'", new Token(new TextAttribute(new Color(Display.getCurrent(), new RGB(255, 0, 0))))); //$NON-NLS-1$ //$NON-NLS-2$ + scanner.setRules(rules); + DefaultDamagerRepairer dr= new DefaultDamagerRepairer(scanner); + this.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); + this.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); + } + +} diff --git a/org.eclipse.ui.genericeditor.tests/test.xml b/org.eclipse.ui.genericeditor.tests/test.xml new file mode 100644 index 00000000000..7c11fd6b726 --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/test.xml @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<project name="testsuite" default="run" basedir="."> + <!-- The property ${eclipse-home} should be passed into this script --> + <!-- Set a meaningful default value for when it is not. --> + <property name="eclipse-home" value="${basedir}\..\.."/> + + <!-- sets the properties eclipse-home, and library-file --> + <property name="plugin-name" value="org.eclipse.ui.editors.tests"/> + <property name="library-file" + value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/> + + <!-- This target holds all initialization code that needs to be done for --> + <!-- all tests that are to be run. Initialization for individual tests --> + <!-- should be done within the body of the suite target. --> + <target name="init"> + <tstamp/> + <delete> + <fileset dir="${eclipse-home}" includes="org*.xml"/> + </delete> + </target> + + <!-- This target defines the tests that need to be run. --> + <target name="suite"> + <property name="eclipse-editors-folder" + value="${eclipse-home}/eclipse_editors_folder"/> + <delete dir="${eclipse-editors-folder}" quiet="true"/> + <ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}"> + <property name="data-dir" value="${eclipse-editors-folder}"/> + <property name="plugin-name" value="${plugin-name}"/> + <property name="classname" + value="org.eclipse.ui.genericeditor.tests.EditorsTestSuite"/> + </ant> + </target> + + <!-- This target holds code to cleanup the testing environment after --> + <!-- after all of the tests have been run. You can use this target to --> + <!-- delete temporary files that have been created. --> + <target name="cleanup"> + </target> + + <!-- This target runs the test suite. Any actions that need to happen --> + <!-- after all the tests have been run should go here. --> + <target name="run" depends="init,suite,cleanup"> + <ant target="collect" antfile="${library-file}" dir="${eclipse-home}"> + <property name="includes" value="org*.xml"/> + <property name="output-file" value="${plugin-name}.xml"/> + </ant> + </target> + + <!-- This target runs the performance test suites. + Disabled for bug 442533: We should not have empty performance targets + <target name="performance"> + </target> + --> + +</project> diff --git a/org.eclipse.ui.genericeditor/.classpath b/org.eclipse.ui.genericeditor/.classpath new file mode 100644 index 00000000000..eca7bdba8f0 --- /dev/null +++ b/org.eclipse.ui.genericeditor/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/org.eclipse.ui.genericeditor/.project b/org.eclipse.ui.genericeditor/.project new file mode 100644 index 00000000000..e1f2994e5af --- /dev/null +++ b/org.eclipse.ui.genericeditor/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.ui.genericeditor</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> diff --git a/org.eclipse.ui.genericeditor/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ui.genericeditor/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..0c68a61dca8 --- /dev/null +++ b/org.eclipse.ui.genericeditor/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/org.eclipse.ui.genericeditor/META-INF/MANIFEST.MF b/org.eclipse.ui.genericeditor/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..ca7ab11688a --- /dev/null +++ b/org.eclipse.ui.genericeditor/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Generic and Extensible Text Editor +Bundle-SymbolicName: org.eclipse.ui.genericeditor;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: Eclipse.org +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.ui.workbench.texteditor;bundle-version="3.10.0", + org.eclipse.ui.editors;bundle-version="3.10.0", + org.eclipse.ui;bundle-version="3.108.0", + org.eclipse.text;bundle-version="3.6.0", + org.eclipse.jface.text;bundle-version="3.11.0", + org.eclipse.core.runtime;bundle-version="3.12.0" +Export-Package: org.eclipse.ui.internal.genericeditor;x-internal:=true +Bundle-Activator: org.eclipse.ui.internal.genericeditor.GenericEditorPlugin +Bundle-Localization: plugin +Bundle-ActivationPolicy: lazy diff --git a/org.eclipse.ui.genericeditor/build.properties b/org.eclipse.ui.genericeditor/build.properties new file mode 100644 index 00000000000..bef8e620327 --- /dev/null +++ b/org.eclipse.ui.genericeditor/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + plugin.properties,\ + icons/ diff --git a/org.eclipse.ui.genericeditor/icons/full/obj16/geneditor.png b/org.eclipse.ui.genericeditor/icons/full/obj16/geneditor.png Binary files differnew file mode 100644 index 00000000000..25b7217874f --- /dev/null +++ b/org.eclipse.ui.genericeditor/icons/full/obj16/geneditor.png diff --git a/org.eclipse.ui.genericeditor/plugin.properties b/org.eclipse.ui.genericeditor/plugin.properties new file mode 100644 index 00000000000..b6a2e26f60c --- /dev/null +++ b/org.eclipse.ui.genericeditor/plugin.properties @@ -0,0 +1,10 @@ +genericEditor_name=Generic Text Editor +ExtPoint.presentationReconciliers=Presentation Reconciliers +ExtPoint.hoverProvider= Hover Providers +ExtPoint.contentAssistProcessors=Content Assist Providers +openDeclarationCommand_name=Open Declaration +openDeclarationCommand_name=Open Declaration for selected element +context_name=in Generic Code Editor +context_description=When editing in the Generic Code Editor +findReferencesCommand_name=Find References +findReferencesCommand_description=Find other code items referencing the current selected item.
\ No newline at end of file diff --git a/org.eclipse.ui.genericeditor/plugin.xml b/org.eclipse.ui.genericeditor/plugin.xml new file mode 100644 index 00000000000..dba3b9ab914 --- /dev/null +++ b/org.eclipse.ui.genericeditor/plugin.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension-point id="presentationReconcilers" name="%ExtPoint.presentationReconciliers" schema="schema/presentationReconcilers.exsd"/> + <extension-point id="contentAssistProcessors" name="%ExtPoint.contentAssistProcessors" schema="schema/contentAssistProcessors.exsd"/> + <extension-point id="hoverProviders" name="%ExtPoint.hoverProviders" schema="schema/hoverProviders.exsd"/> + <extension + point="org.eclipse.ui.editors"> + <editor + class="org.eclipse.ui.internal.genericeditor.ExtensionBasedTextEditor" + default="false" + icon="icons/full/obj16/geneditor.png" + id="org.eclipse.ui.genericeditor.GenericEditor" + name="%genericEditor_name"> + <contentTypeBinding + contentTypeId="org.eclipse.core.runtime.text"> + </contentTypeBinding> + </editor> + </extension> + <extension + point="org.eclipse.ui.commands"> + <command + description="%findReferencesCommand_description" + id="org.eclipse.ui.genericeditor.findReferences" + name="%findReferencesCommand_name"> + </command> + </extension> + <extension + point="org.eclipse.ui.contexts"> + <context + description="%context_description" + id="org.eclipse.ui.genericeditor.genericEditorContext" + name="%context_name" + parentId="org.eclipse.ui.textEditorScope"> + </context> + </extension> + <extension + point="org.eclipse.ui.bindings"> + <key + commandId="org.eclipse.ui.edit.text.open.hyperlink" + contextId="org.eclipse.ui.genericeditor.genericEditorContext" + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" + sequence="F3"> + </key> + <key + commandId="org.eclipse.ui.genericeditor.findReferences" + contextId="org.eclipse.ui.genericeditor.genericEditorContext" + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" + sequence="M1+M2+G"> + </key> + </extension> + <extension + point="org.eclipse.ui.menus"> + <menuContribution + allPopups="true" + locationURI="popup:#TextEditorContext?after=additions"> + <command + commandId="org.eclipse.ui.genericeditor.findReferences" + style="push"> + </command> + </menuContribution> + </extension> + +</plugin> diff --git a/org.eclipse.ui.genericeditor/pom.xml b/org.eclipse.ui.genericeditor/pom.xml new file mode 100644 index 00000000000..df83a530d13 --- /dev/null +++ b/org.eclipse.ui.genericeditor/pom.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2016 Red Hat Inc. and others. + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Distribution License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/org/documents/edl-v10.php + + Contributors: + Mickael Istria (Red Hat Inc.) - initial implementation +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>eclipse.platform.text</artifactId> + <groupId>eclipse.platform.text</groupId> + <version>4.7.0-SNAPSHOT</version> + </parent> + <groupId>org.eclipse.ui</groupId> + <artifactId>org.eclipse.ui.genericeditor</artifactId> + <version>1.0.0-SNAPSHOT</version> + <packaging>eclipse-plugin</packaging> +</project> diff --git a/org.eclipse.ui.genericeditor/schema/contentAssistProcessors.exsd b/org.eclipse.ui.genericeditor/schema/contentAssistProcessors.exsd new file mode 100644 index 00000000000..441b85ab13f --- /dev/null +++ b/org.eclipse.ui.genericeditor/schema/contentAssistProcessors.exsd @@ -0,0 +1,116 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.ui.genericeditor" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appinfo> + <meta.schema plugin="org.eclipse.ui.genericeditor" id="contentAssistProcessors" name="Content assist processors"/> + </appinfo> + <documentation> + This extension point is used to contribute content assist processors for adding content assist support to a given content type. + </documentation> + </annotation> + + <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/> + + <element name="extension"> + <annotation> + <appinfo> + <meta.element /> + </appinfo> + </annotation> + <complexType> + <sequence minOccurs="1" maxOccurs="unbounded"> + <element ref="contentAssistProcessor"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + a fully qualified identifier of the target extension point + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + an optional identifier of the extension instance + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + an optional name of the extension instance + </documentation> + <appinfo> + <meta.attribute translatable="true"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="contentAssistProcessor"> + <complexType> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + The fully qualified class name implementing the interface <code>org.eclipse.jface.text.contentassist.IContentAssistProcessor</code> + </documentation> + <appinfo> + <meta.attribute kind="java" basedOn=":org.eclipse.jface.text.contentassist.IContentAssistProcessor"/> + </appinfo> + </annotation> + </attribute> + <attribute name="contentType" type="string" use="required"> + <annotation> + <documentation> + The target content-type for this extension. Content-types are defined as extension to the org.eclipse.core.contenttype.contentTypes extension point. + </documentation> + <appinfo> + <meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appinfo> + <meta.section type="since"/> + </appinfo> + <documentation> + 1.0 + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="examples"/> + </appinfo> + <documentation> + This is an example of a processor being registered for a target definition file type: + +<pre> +<extension point="org.eclipse.ui.genericeditor.contentAssistProcessors"> + <contentAssistProcessor + class="org.eclipse.ui.genericeditor.examples.TargedDefinitionContentAssist" + contentType="org.eclipse.pde.targetFile"> + </contentAssistProcessor> +</extension> +</pre> + </documentation> + </annotation> + + + + <annotation> + <appinfo> + <meta.section type="copyright"/> + </appinfo> + <documentation> + Copyright (c) 2016 Red Hat Inc. and others +All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> + </documentation> + </annotation> + +</schema> diff --git a/org.eclipse.ui.genericeditor/schema/hoverProviders.exsd b/org.eclipse.ui.genericeditor/schema/hoverProviders.exsd new file mode 100644 index 00000000000..ac475e82af3 --- /dev/null +++ b/org.eclipse.ui.genericeditor/schema/hoverProviders.exsd @@ -0,0 +1,145 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.ui.genericeditor" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appinfo> + <meta.schema plugin="org.eclipse.ui.genericeditor" id="hoverProviders" name="Hover providers"/> + </appinfo> + <documentation> + This extension point is used to contribute hover providers for showing text hovers in a file with a given content type. + </documentation> + </annotation> + + <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/> + + <element name="extension"> + <annotation> + <appinfo> + <meta.element /> + </appinfo> + </annotation> + <complexType> + <sequence> + <element ref="hoverProvider" minOccurs="1" maxOccurs="unbounded"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + a fully qualified identifier of the target extension point + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + an optional identifier of the extension instance + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + an optional name of the extension instance + </documentation> + <appinfo> + <meta.attribute translatable="true"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="hoverProvider"> + <complexType> + <attribute name="id" type="string"> + <annotation> + <documentation> + A string uniquely identifying this reference provider. + </documentation> + </annotation> + </attribute> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + The fully qualified class name implementing the interface <code>org.eclipse.jface.text.ITextHover</code> + </documentation> + <appinfo> + <meta.attribute kind="java" basedOn=":org.eclipse.jface.text.ITextHover"/> + </appinfo> + </annotation> + </attribute> + <attribute name="contentType" type="string" use="required"> + <annotation> + <documentation> + The target content-type for this extension. Content-types are defined as extension to the org.eclipse.core.contenttype.contentTypes extension point. + </documentation> + <appinfo> + <meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/> + </appinfo> + </annotation> + </attribute> + <attribute name="before" type="string"> + <annotation> + <documentation> + The id of a hoverProvider before which to place this contribution. +Plan is to have contributions are sorted according to that value and to have only the first one shown (or the the first "compoundable" ones) + </documentation> + <appinfo> + <meta.attribute kind="identifier" basedOn="org.eclipse.ui.genericeditor.hoverProviders/hoverProvider/@id"/> + </appinfo> + </annotation> + </attribute> + <attribute name="after" type="string"> + <annotation> + <documentation> + The id of a hoverProvider after which to place this contribution. +Plan is to have contributions are sorted according to that value and to have only the first one shown (or the the first "compoundable" ones) + </documentation> + <appinfo> + <meta.attribute kind="identifier" basedOn="org.eclipse.ui.genericeditor.hoverProviders/hoverProvider/@id"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appinfo> + <meta.section type="since"/> + </appinfo> + <documentation> + 1.0 + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="examples"/> + </appinfo> + <documentation> + Below is an example using the hover provider extension point: + +<pre> +<extension point="org.eclipse.ui.genericeditor.hoverProviders"> + <hoverProvider + class="org.eclipse.ui.genericeditor.tests.contributions.MagicHoverProvider" + contentType="org.eclipse.core.runtime.text"> + </hoverProvider> +</extension> +</pre> + </documentation> + </annotation> + + + + <annotation> + <appinfo> + <meta.section type="copyright"/> + </appinfo> + <documentation> + Copyright (c) 2016 Red Hat Inc. and others +All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> + </documentation> + </annotation> + +</schema> diff --git a/org.eclipse.ui.genericeditor/schema/presentationReconcilers.exsd b/org.eclipse.ui.genericeditor/schema/presentationReconcilers.exsd new file mode 100644 index 00000000000..17aca3a3506 --- /dev/null +++ b/org.eclipse.ui.genericeditor/schema/presentationReconcilers.exsd @@ -0,0 +1,116 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.ui.genericeditor" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appinfo> + <meta.schema plugin="org.eclipse.ui.genericeditor" id="presentationReconcilers" name="Presentation reconcilers"/> + </appinfo> + <documentation> + This extension point is used to contribute presentation reconcilers for controlling the presentation on a file with a given content type. + </documentation> + </annotation> + + <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/> + + <element name="extension"> + <annotation> + <appinfo> + <meta.element /> + </appinfo> + </annotation> + <complexType> + <sequence minOccurs="1" maxOccurs="unbounded"> + <element ref="presentationReconciler"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + a fully qualified identifier of the target extension point + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + an optional identifier of the extension instance + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + an optional name of the extension instance + </documentation> + <appinfo> + <meta.attribute translatable="true"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="presentationReconciler"> + <complexType> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + The fully qualified class name implementing the interface <code>org.eclipse.jface.text.presentation.IPresentationReconciler</code> + </documentation> + <appinfo> + <meta.attribute kind="java" basedOn=":org.eclipse.jface.text.presentation.IPresentationReconciler"/> + </appinfo> + </annotation> + </attribute> + <attribute name="contentType" type="string" use="required"> + <annotation> + <documentation> + The target content-type for this extension. Content-types are defined as extension to the org.eclipse.core.contenttype.contentTypes extension point. + </documentation> + <appinfo> + <meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appinfo> + <meta.section type="since"/> + </appinfo> + <documentation> + 1.0 + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="examples"/> + </appinfo> + <documentation> + Below is an example of how to use the Presentation Reconciler extension point: + +<pre> +<extension point="org.eclipse.ui.genericeditor.presentationReconcilers"> + <presentationReconciler + class="org.eclipse.ui.genericeditor.examples.TPPresentationReconciler" + contentType="org.eclipse.pde.targetFile"> + </presentationReconciler> +</extension> +</pre> + </documentation> + </annotation> + + + + <annotation> + <appinfo> + <meta.section type="copyright"/> + </appinfo> + <documentation> + Copyright (c) 2016 Red Hat Inc. and others +All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> + </documentation> + </annotation> + +</schema> diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeContentAssistProcessor.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeContentAssistProcessor.java new file mode 100644 index 00000000000..d4d64acee51 --- /dev/null +++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CompositeContentAssistProcessor.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2016 Red Hat Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * - Mickael Istria (Red Hat Inc.) + *******************************************************************************/ +package org.eclipse.ui.internal.genericeditor; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jface.text.ITextViewer; +import org.eclipse.jface.text.contentassist.ICompletionProposal; +import org.eclipse.jface.text.contentassist.IContentAssistProcessor; +import org.eclipse.jface.text.contentassist.IContextInformation; +import org.eclipse.jface.text.contentassist.IContextInformationValidator; + +/** + * A content assist processor that delegates all content assist + * operations to children provided in constructor and aggregates + * the results. + * + * @since 1.0 + */ +public class CompositeContentAssistProcessor implements IContentAssistProcessor { + + private List<IContentAssistProcessor> fContentAssistProcessors; + + /** + * Constructor + * @param contentAssistProcessors the children that will actually populate the output + * of this content assist processor. + */ + public CompositeContentAssistProcessor(List<IContentAssistProcessor> contentAssistProcessors) { + fContentAssistProcessors= contentAssistProcessors; + } + + @Override + public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { + List<ICompletionProposal> res = new ArrayList<>(); + for (IContentAssistProcessor processor : this.fContentAssistProcessors) { + res.addAll(Arrays.asList(processor.computeCompletionProposals(viewer, offset))); + } + return res.toArray(new ICompletionProposal[res.size()]); + } + + @Override + public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { + List<IContextInformation> res = new ArrayList<>(); + for (IContentAssistProcessor processor : this.fContentAssistProcessors) { + res.addAll(Arrays.asList(processor.computeContextInformation(viewer, offset))); + } + return res.toArray(new IContextInformation[res.size()]); + } + + @Override + public char[] getCompletionProposalAutoActivationCharacters() { + return null; + } + + @Override + public char[] getContextInformationAutoActivationCharacters() { + return null; + } + + @Override + public String getErrorMessage() { + StringBuilder res = new StringBuilder(); + for (IContentAssistProcessor processor : this.fContentAssistProcessors) { + String errorMessage = processor.getErrorMessage(); + if (errorMessage != null) { + res.append(errorMessage); + res.append('\n'); + } + } + if (res.length() == 0) { + return null; + } else { + return res.toString(); + } + } + + @Override + public IContextInformationValidator getContextInformationValidator() { + return null; + } + +}
\ No newline at end of file diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ContentAssistProcessorRegistry.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ContentAssistProcessorRegistry.java new file mode 100644 index 00000000000..a81cecbf8f0 --- /dev/null +++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ContentAssistProcessorRegistry.java @@ -0,0 +1,195 @@ +/******************************************************************************* + * Copyright (c) 2016 Red Hat Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * - Mickael Istria (Red Hat Inc.) + *******************************************************************************/ +package org.eclipse.ui.internal.genericeditor; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IRegistryChangeEvent; +import org.eclipse.core.runtime.IRegistryChangeListener; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.core.runtime.content.IContentTypeManager; +import org.eclipse.jface.text.ITextViewer; +import org.eclipse.jface.text.contentassist.ICompletionProposal; +import org.eclipse.jface.text.contentassist.IContentAssistProcessor; +import org.eclipse.jface.text.contentassist.IContextInformation; +import org.eclipse.jface.text.contentassist.IContextInformationValidator; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.PlatformUI; + +/** + * A registry of content assist processors provided by extension <code>org.eclipse.ui.genericeditor.contentAssistProcessors</code>. + * Those extensions are specific to a given {@link IContentType}. + * + * @since 1.0 + */ +public class ContentAssistProcessorRegistry { + + private static final String EXTENSION_POINT_ID = GenericEditorPlugin.BUNDLE_ID + ".contentAssistProcessors"; //$NON-NLS-1$ + + /** + * This class wraps and proxies an {@link IContentAssistProcessor} provided through extensions + * and loads it lazily when it can contribute to the editor, then delegates all operations to + * actual processor. + * When the contribution cannot contribute to the editor, this wrapper will return neutral values + * that don't affect editor behavior. + */ + private static class ContentAssistProcessorExtension implements IContentAssistProcessor { + private static final String CONTENT_TYPE_ATTRIBUTE = "contentType"; //$NON-NLS-1$ + private static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$ + + private IConfigurationElement extension; + private IContentType targetContentType; + + private IContentAssistProcessor delegate; + + private ContentAssistProcessorExtension(IConfigurationElement element) throws Exception { + this.extension = element; + this.targetContentType = Platform.getContentTypeManager().getContentType(element.getAttribute(CONTENT_TYPE_ATTRIBUTE)); + } + + private IContentAssistProcessor getDelegate() { + if (this.delegate == null) { + try { + this.delegate = (IContentAssistProcessor) extension.createExecutableExtension(CLASS_ATTRIBUTE); + } catch (CoreException e) { + e.printStackTrace(); + } + } + return delegate; + } + + /** + * @return whether the referenced contribution should contribute to the current editor. + */ + public boolean isActive() { + IEditorInput input = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput(); + IContentTypeManager contentTypeManager= Platform.getContentTypeManager(); + for (IContentType currentContentType : contentTypeManager.findContentTypesFor(input.getName())) { + if (currentContentType.isKindOf(targetContentType)) { + return true; + } + } + return false; + } + + @Override + public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { + if (isActive()) { + return getDelegate().computeCompletionProposals(viewer, offset); + } + return new ICompletionProposal[0]; + } + + @Override + public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { + if (isActive()) { + return getDelegate().computeContextInformation(viewer, offset); + } + return new IContextInformation[0]; + } + + @Override + public char[] getCompletionProposalAutoActivationCharacters() { + if (isActive()) { + return getDelegate().getCompletionProposalAutoActivationCharacters(); + } + return null; + } + + @Override + public char[] getContextInformationAutoActivationCharacters() { + if (isActive()) { + return getDelegate().getContextInformationAutoActivationCharacters(); + } + return null; + } + + @Override + public String getErrorMessage() { + if (isActive()) { + return getDelegate().getErrorMessage(); + } + return null; + } + + @Override + public IContextInformationValidator getContextInformationValidator() { + if (isActive()) { + return getDelegate().getContextInformationValidator(); + } + return null; + } + } + + private Map<IConfigurationElement, ContentAssistProcessorExtension> extensions = new HashMap<>(); + private boolean outOfSync = true; + + /** + * Creates the registry and binds it to the extension point. + */ + public ContentAssistProcessorRegistry() { + Platform.getExtensionRegistry().addRegistryChangeListener(new IRegistryChangeListener() { + @Override + public void registryChanged(IRegistryChangeEvent event) { + outOfSync = true; + } + }, EXTENSION_POINT_ID); + } + + /** + * Get the contributed {@link IContentAssistProcessor}s that are relevant to hook on source viewer according + * to document content types. + * @param sourceViewer the source viewer we're hooking completion to. + * @param contentTypes the content types of the document we're editing. + * @return the list of {@link IContentAssistProcessor} contributed for at least one of the content types. + */ + public List<IContentAssistProcessor> getContentAssistProcessors(ISourceViewer sourceViewer, Set<IContentType> contentTypes) { + if (this.outOfSync) { + sync(); + } + List<IContentAssistProcessor> res = new ArrayList<>(); + for (ContentAssistProcessorExtension ext : this.extensions.values()) { + if (contentTypes.contains(ext.targetContentType)) { + res.add(ext); + } + } + return res; + } + + private void sync() { + Set<IConfigurationElement> toRemoveExtensions = new HashSet<>(this.extensions.keySet()); + for (IConfigurationElement extension : Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID)) { + toRemoveExtensions.remove(extension); + if (!this.extensions.containsKey(extension)) { + try { + this.extensions.put(extension, new ContentAssistProcessorExtension(extension)); + } catch (Exception ex) { + GenericEditorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, ex.getMessage(), ex)); + } + } + } + for (IConfigurationElement toRemove : toRemoveExtensions) { + this.extensions.remove(toRemove); + } + this.outOfSync = false; + } +} diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextEditor.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextEditor.java new file mode 100644 index 00000000000..467be5318d4 --- /dev/null +++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextEditor.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2000, 2016 Red Hat Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sopot Cela, Mickael Istria (Red Hat Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.ui.internal.genericeditor; + +import org.eclipse.ui.editors.text.TextEditor; + +/** + * A generic code editor that is aimed at being extended by contributions. Behavior + * is supposed to be added via extensions, not by inheritance. + * + * @since 1.0 + */ +public class ExtensionBasedTextEditor extends TextEditor { + + private static final String CONTEXT_ID = "org.eclipse.ui.genericeditor.genericEditorContext"; //$NON-NLS-1$ + + /** + * + */ + public ExtensionBasedTextEditor() { + setSourceViewerConfiguration(new ExtensionBasedTextViewerConfiguration(this, getPreferenceStore())); + } + + @Override + protected void setKeyBindingScopes(String[] scopes) { + super.setKeyBindingScopes(new String[] { CONTEXT_ID }); + } + +} diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextViewerConfiguration.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextViewerConfiguration.java new file mode 100644 index 00000000000..d8d2b21c423 --- /dev/null +++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextViewerConfiguration.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright (c) 2016 Red Hat Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sopot Cela, Mickael Istria (Red Hat Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.ui.internal.genericeditor; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.text.AbstractReusableInformationControlCreator; +import org.eclipse.jface.text.DefaultInformationControl; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IInformationControl; +import org.eclipse.jface.text.ITextHover; +import org.eclipse.jface.text.contentassist.ContentAssistant; +import org.eclipse.jface.text.contentassist.IContentAssistProcessor; +import org.eclipse.jface.text.contentassist.IContentAssistant; +import org.eclipse.jface.text.presentation.IPresentationReconciler; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.editors.text.TextSourceViewerConfiguration; + +/** + * The configuration of the {@link ExtensionBasedTextEditor}. It registers the proxy composite + * for hover, completion, syntax highlighting, and then those proxy take care of resolving to + * the right extensions on-demand. + * + * @since 1.0 + */ +public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewerConfiguration { + + private IEditorPart editor; + private Set<IContentType> contentTypes; + + /** + * + * @param editor the editor we're creating. + * @param preferenceStore the preference store. + */ + public ExtensionBasedTextViewerConfiguration(IEditorPart editor, IPreferenceStore preferenceStore) { + super(preferenceStore); + this.editor = editor; + } + + private Set<IContentType> getContentTypes() { + if (this.contentTypes == null) { + this.contentTypes = new HashSet<>(Arrays.asList(Platform.getContentTypeManager().findContentTypesFor(editor.getEditorInput().getName()))); + } + return this.contentTypes; + } + + @Override + public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { + TextHoverRegistry registry= GenericEditorPlugin.getDefault().getHoverRegistry(); + return registry.getAvailableHover(sourceViewer, getContentTypes()); + } + + @Override + public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { + ContentAssistProcessorRegistry registry= GenericEditorPlugin.getDefault().getContentAssistProcessorRegistry(); + IContentAssistProcessor processor = new CompositeContentAssistProcessor(registry.getContentAssistProcessors(sourceViewer, getContentTypes())); + ContentAssistant res= new ContentAssistant(); + res.setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_BELOW); + res.setProposalPopupOrientation(ContentAssistant.PROPOSAL_REMOVE); + res.enableColoredLabels(true); + res.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE); + res.setInformationControlCreator(new AbstractReusableInformationControlCreator() { + @Override + protected IInformationControl doCreateInformationControl(Shell parent) { + return new DefaultInformationControl(parent); + } + }); + return res; + } + + @Override + public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) { + PresentationReconcilerRegistry registry = GenericEditorPlugin.getDefault().getPresentationReconcilerRegistry(); + List<IPresentationReconciler> reconciliers = registry.getPresentationReconcilers(sourceViewer, getContentTypes()); + if (!reconciliers.isEmpty()) { + return reconciliers.get(0); + } + return null; + } + +} diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/GenericEditorPlugin.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/GenericEditorPlugin.java new file mode 100644 index 00000000000..e5f33d470cc --- /dev/null +++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/GenericEditorPlugin.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2016 Red Hat Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sopot Cela, Mickael Istria (Red Hat Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.ui.internal.genericeditor; + +import org.eclipse.jface.text.ITextHover; +import org.eclipse.jface.text.contentassist.IContentAssistProcessor; +import org.eclipse.jface.text.presentation.IPresentationReconciler; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * Generic editor plugin activator and singletons. + * + * @since 1.0 + */ +public class GenericEditorPlugin extends AbstractUIPlugin { + + public static final String BUNDLE_ID = "org.eclipse.ui.genericeditor"; //$NON-NLS-1$ + + private static GenericEditorPlugin INSTANCE; + + private TextHoverRegistry textHoversRegistry; + private ContentAssistProcessorRegistry contentAssistProcessorsRegistry; + private PresentationReconcilerRegistry presentationReconcilierRegistry; + + @Override + public void start(BundleContext context) throws Exception{ + INSTANCE = this; + super.start(context); + } + + @Override + public void stop(BundleContext context) throws Exception { + super.stop(context); + INSTANCE = null; + } + + public static GenericEditorPlugin getDefault() { + return INSTANCE; + } + + /** + * @return the registry allowing to access contributed {@link ITextHover}s. + * @since 1.0 + */ + public synchronized TextHoverRegistry getHoverRegistry() { + if (this.textHoversRegistry == null) { + this.textHoversRegistry = new TextHoverRegistry(getPreferenceStore()); + } + return this.textHoversRegistry; + } + + /** + * @return the registry allowing to access contributed {@link IContentAssistProcessor}s. + * @since 1.0 + */ + public synchronized ContentAssistProcessorRegistry getContentAssistProcessorRegistry() { + if (this.contentAssistProcessorsRegistry == null) { + this.contentAssistProcessorsRegistry = new ContentAssistProcessorRegistry(); + } + return this.contentAssistProcessorsRegistry; + } + + /** + * @return the registry allowing to access contributed {@link IPresentationReconciler}s. + * @since 1.0 + */ + public synchronized PresentationReconcilerRegistry getPresentationReconcilerRegistry() { + if (this.presentationReconcilierRegistry == null) { + this.presentationReconcilierRegistry = new PresentationReconcilerRegistry(); + } + return this.presentationReconcilierRegistry; + } +} diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/PresentationReconcilerRegistry.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/PresentationReconcilerRegistry.java new file mode 100644 index 00000000000..b973b816cf2 --- /dev/null +++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/PresentationReconcilerRegistry.java @@ -0,0 +1,149 @@ +/******************************************************************************* + * Copyright (c) 2016 Red Hat Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sopot Cela, Mickael Istria (Red Hat Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.ui.internal.genericeditor; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IRegistryChangeEvent; +import org.eclipse.core.runtime.IRegistryChangeListener; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.jface.text.ITextViewer; +import org.eclipse.jface.text.presentation.IPresentationDamager; +import org.eclipse.jface.text.presentation.IPresentationReconciler; +import org.eclipse.jface.text.presentation.IPresentationRepairer; +import org.eclipse.jface.text.source.ISourceViewer; + +/** + * A registry of presentation reconciliers provided by extension <code>org.eclipse.ui.genericeditor.presentationReconcilers</code>. + * Those extensions are specific to a given {@link IContentType}. + * + * @since 1.0 + */ +public class PresentationReconcilerRegistry { + + private static final String EXTENSION_POINT_ID = GenericEditorPlugin.BUNDLE_ID + ".presentationReconcilers"; //$NON-NLS-1$ + + /** + * This class wraps and proxies an {@link IPresentationReconcilier} provided through extensions + * and loads it lazily when it can contribute to the editor, then delegates all operations to + * actual reconcilier. + */ + private static class PresentationReconcilerExtension implements IPresentationReconciler { + private static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$ + private static final String CONTENT_TYPE_ATTRIBUTE = "contentType"; //$NON-NLS-1$ + + private IConfigurationElement extension; + private IContentType targetContentType; + + private IPresentationReconciler delegate; + + private PresentationReconcilerExtension(IConfigurationElement element) throws Exception { + this.extension = element; + this.targetContentType = Platform.getContentTypeManager().getContentType(element.getAttribute(CONTENT_TYPE_ATTRIBUTE)); + } + + private IPresentationReconciler getDelegate() { + if (this.delegate == null) { + try { + this.delegate = (IPresentationReconciler) extension.createExecutableExtension(CLASS_ATTRIBUTE); + } catch (CoreException e) { + e.printStackTrace(); + } + } + return delegate; + } + + @Override + public void install(ITextViewer viewer) { + getDelegate().install(viewer); + } + + @Override + public void uninstall() { + getDelegate().uninstall(); + } + + @Override + public IPresentationDamager getDamager(String contentType) { + return getDelegate().getDamager(contentType); + + } + + @Override + public IPresentationRepairer getRepairer(String contentType) { + return getDelegate().getRepairer(contentType); + } + + } + private Map<IConfigurationElement, PresentationReconcilerExtension> extensions = new HashMap<>(); + private boolean outOfSync = true; + + /** + * Creates the registry and binds it to the extension point. + */ + public PresentationReconcilerRegistry() { + Platform.getExtensionRegistry().addRegistryChangeListener(new IRegistryChangeListener() { + @Override + public void registryChanged(IRegistryChangeEvent event) { + outOfSync = true; + } + }, EXTENSION_POINT_ID); + } + + /** + * Get the contributed {@link IPresentationReconciliers}s that are relevant to hook on source viewer according + * to document content types. + * @param sourceViewer the source viewer we're hooking completion to. + * @param contentTypes the content types of the document we're editing. + * @return the list of {@link IPresentationReconciler} contributed for at least one of the content types. + */ + public List<IPresentationReconciler> getPresentationReconcilers(ISourceViewer sourceViewer, Set<IContentType> contentTypes) { + if (this.outOfSync) { + sync(); + } + List<IPresentationReconciler> res = new ArrayList<>(); + for (PresentationReconcilerExtension ext : this.extensions.values()) { + if (contentTypes.contains(ext.targetContentType)) { + res.add(ext); + } + } + return res; + } + + private void sync() { + Set<IConfigurationElement> toRemoveExtensions = new HashSet<>(this.extensions.keySet()); + for (IConfigurationElement extension : Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID)) { + toRemoveExtensions.remove(extension); + if (!this.extensions.containsKey(extension)) { + try { + this.extensions.put(extension, new PresentationReconcilerExtension(extension)); + } catch (Exception ex) { + GenericEditorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, ex.getMessage(), ex)); + } + } + } + for (IConfigurationElement toRemove : toRemoveExtensions) { + this.extensions.remove(toRemove); + } + this.outOfSync = false; + } + +} diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/TextHoverRegistry.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/TextHoverRegistry.java new file mode 100644 index 00000000000..88e4825f66c --- /dev/null +++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/TextHoverRegistry.java @@ -0,0 +1,111 @@ +/******************************************************************************* + * Copyright (c) 2016 Red Hat Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * - Mickael Istria (Red Hat Inc.) + *******************************************************************************/ +package org.eclipse.ui.internal.genericeditor; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IRegistryChangeEvent; +import org.eclipse.core.runtime.IRegistryChangeListener; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.text.ITextHover; +import org.eclipse.jface.text.source.ISourceViewer; + +/** + * Text hover registry that manages the detectors + * contributed by the <code>org.eclipse.ui.workbench.texteditor.hoverProvider</code> extension point for + * targets contributed by the <code>org.eclipse.ui.workbench.texteditor.hyperlinkDetectorTargets</code> extension point. + * + * @since 1.0 + */ +public final class TextHoverRegistry { + + private static final String EXTENSION_POINT_ID = GenericEditorPlugin.BUNDLE_ID + ".hoverProviders"; //$NON-NLS-1$ + + private Map<IConfigurationElement, TextHoverExtension> extensions = new HashMap<>(); + private boolean outOfSync = true; + + private static class TextHoverExtension { + private static final String CONTENT_TYPE_ATTRIBUTE = "contentType"; //$NON-NLS-1$ + private static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$ + + private IConfigurationElement extension; + private IContentType targetContentType; + private ITextHover delegate; + + public TextHoverExtension(IConfigurationElement extension) throws Exception { + this.extension = extension; + this.targetContentType = Platform.getContentTypeManager().getContentType(extension.getAttribute(CONTENT_TYPE_ATTRIBUTE)); + } + + private ITextHover getDelegate() { + if (this.delegate == null) { + try { + this.delegate = (ITextHover) extension.createExecutableExtension(CLASS_ATTRIBUTE); + } catch (CoreException e) { + e.printStackTrace(); + } + } + return delegate; + } + + } + + public TextHoverRegistry(IPreferenceStore preferenceStore) { + Platform.getExtensionRegistry().addRegistryChangeListener(new IRegistryChangeListener() { + @Override + public void registryChanged(IRegistryChangeEvent event) { + outOfSync = true; + } + }, EXTENSION_POINT_ID); + } + + public ITextHover getAvailableHover(ISourceViewer sourceViewer, Set<IContentType> contentTypes) { + if (this.outOfSync) { + sync(); + } + // TODO rather that returning the 1st active hover, consider + // supporting compound/aggregated hovers. + for (TextHoverExtension ext : this.extensions.values()) { + if (contentTypes.contains(ext.targetContentType)) { + return ext.getDelegate(); + } + } + return null; + } + + private void sync() { + Set<IConfigurationElement> toRemoveExtensions = new HashSet<>(this.extensions.keySet()); + for (IConfigurationElement extension : Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID)) { + toRemoveExtensions.remove(extension); + if (!this.extensions.containsKey(extension)) { + try { + this.extensions.put(extension, new TextHoverExtension(extension)); + } catch (Exception ex) { + GenericEditorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, ex.getMessage(), ex)); + } + } + } + for (IConfigurationElement toRemove : toRemoveExtensions) { + this.extensions.remove(toRemove); + } + this.outOfSync = false; + } + +} @@ -5,7 +5,7 @@ are made available under the terms of the Eclipse Distribution License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/org/documents/edl-v10.php - + Contributors: Igor Fedorenko - initial implementation --> @@ -28,11 +28,11 @@ <tycho.scmUrl>scm:git:git://git.eclipse.org/gitroot/platform/eclipse.platform.text.git</tycho.scmUrl> </properties> - <!-- - To build individual bundles, we specify a repository where to find parent pom, + <!-- + To build individual bundles, we specify a repository where to find parent pom, in case it is not in local maven cache already - and that parent pom also has fuller individual-bundle profile - defined that is combined with this one. --> + and that parent pom also has fuller individual-bundle profile + defined that is combined with this one. --> <profiles> <profile> <id>build-individual-bundles</id> @@ -65,6 +65,9 @@ <module>org.eclipse.ui.editors</module> <module>org.eclipse.search</module> <module>org.eclipse.ui.examples.javaeditor</module> + <!-- Generic editor --> + <module>org.eclipse.ui.genericeditor</module> + <module>org.eclipse.ui.genericeditor.tests</module> </modules> </project> |