|
Lines 12-18
Link Here
|
| 12 |
|
12 |
|
| 13 |
import java.util.ArrayList; |
13 |
import java.util.ArrayList; |
| 14 |
import java.util.List; |
14 |
import java.util.List; |
|
|
15 |
import java.util.Vector; |
| 15 |
|
16 |
|
|
|
17 |
import org.eclipse.core.runtime.Preferences; |
| 16 |
import org.eclipse.jdt.ui.PreferenceConstants; |
18 |
import org.eclipse.jdt.ui.PreferenceConstants; |
| 17 |
import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration; |
19 |
import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration; |
| 18 |
import org.eclipse.jdt.ui.text.JavaTextTools; |
20 |
import org.eclipse.jdt.ui.text.JavaTextTools; |
|
Lines 38-44
Link Here
|
| 38 |
import org.eclipse.wst.css.core.internal.provisional.text.ICSSPartitionTypes; |
40 |
import org.eclipse.wst.css.core.internal.provisional.text.ICSSPartitionTypes; |
| 39 |
import org.eclipse.wst.css.ui.internal.contentassist.CSSContentAssistProcessor; |
41 |
import org.eclipse.wst.css.ui.internal.contentassist.CSSContentAssistProcessor; |
| 40 |
import org.eclipse.wst.css.ui.internal.style.LineStyleProviderForEmbeddedCSS; |
42 |
import org.eclipse.wst.css.ui.internal.style.LineStyleProviderForEmbeddedCSS; |
|
|
43 |
import org.eclipse.wst.html.core.internal.HTMLCorePlugin; |
| 41 |
import org.eclipse.wst.html.core.internal.format.HTMLFormatProcessorImpl; |
44 |
import org.eclipse.wst.html.core.internal.format.HTMLFormatProcessorImpl; |
|
|
45 |
import org.eclipse.wst.html.core.internal.preferences.HTMLCorePreferenceNames; |
| 42 |
import org.eclipse.wst.html.core.internal.provisional.text.IHTMLPartitionTypes; |
46 |
import org.eclipse.wst.html.core.internal.provisional.text.IHTMLPartitionTypes; |
| 43 |
import org.eclipse.wst.html.core.internal.text.StructuredTextPartitionerForHTML; |
47 |
import org.eclipse.wst.html.core.internal.text.StructuredTextPartitionerForHTML; |
| 44 |
import org.eclipse.wst.html.ui.internal.contentassist.HTMLContentAssistProcessor; |
48 |
import org.eclipse.wst.html.ui.internal.contentassist.HTMLContentAssistProcessor; |
|
Lines 79-105
Link Here
|
| 79 |
InformationPresenter fInformationPresenter = null; |
83 |
InformationPresenter fInformationPresenter = null; |
| 80 |
|
84 |
|
| 81 |
private JavaSourceViewerConfiguration fJavaSourceViewerConfiguration; |
85 |
private JavaSourceViewerConfiguration fJavaSourceViewerConfiguration; |
| 82 |
|
86 |
|
| 83 |
public StructuredTextViewerConfigurationHTML() { |
87 |
public StructuredTextViewerConfigurationHTML() { |
| 84 |
super(); |
88 |
super(); |
| 85 |
} |
89 |
} |
| 86 |
|
90 |
|
| 87 |
public StructuredTextViewerConfigurationHTML(IPreferenceStore store) { |
91 |
public StructuredTextViewerConfigurationHTML(IPreferenceStore store) { |
| 88 |
super(store); |
92 |
super(store); |
| 89 |
} |
93 |
} |
| 90 |
|
94 |
|
| 91 |
|
95 |
|
| 92 |
/* (non-Javadoc) |
96 |
/* |
| 93 |
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAutoEditStrategies(org.eclipse.jface.text.source.ISourceViewer, java.lang.String) |
97 |
* (non-Javadoc) |
|
|
98 |
* |
| 99 |
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAutoEditStrategies(org.eclipse.jface.text.source.ISourceViewer, |
| 100 |
* java.lang.String) |
| 94 |
*/ |
101 |
*/ |
| 95 |
public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) { |
102 |
public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) { |
| 96 |
List allStrategies = new ArrayList(0); |
103 |
List allStrategies = new ArrayList(0); |
| 97 |
|
104 |
|
| 98 |
IAutoEditStrategy[] superStrategies = super.getAutoEditStrategies(sourceViewer, contentType); |
105 |
IAutoEditStrategy[] superStrategies = super.getAutoEditStrategies(sourceViewer, contentType); |
| 99 |
for (int i = 0; i < superStrategies.length; i++) { |
106 |
for (int i = 0; i < superStrategies.length; i++) { |
| 100 |
allStrategies.add(superStrategies[i]); |
107 |
allStrategies.add(superStrategies[i]); |
| 101 |
} |
108 |
} |
| 102 |
|
109 |
|
| 103 |
if (contentType == IHTMLPartitionTypes.HTML_DEFAULT || contentType == IHTMLPartitionTypes.HTML_DECLARATION) { |
110 |
if (contentType == IHTMLPartitionTypes.HTML_DEFAULT || contentType == IHTMLPartitionTypes.HTML_DECLARATION) { |
| 104 |
allStrategies.add(new StructuredAutoEditStrategyXML()); |
111 |
allStrategies.add(new StructuredAutoEditStrategyXML()); |
| 105 |
} |
112 |
} |
|
Lines 248-253
Link Here
|
| 248 |
fInformationPresenter.setInformationProvider(javascriptInformationProvider, IHTMLPartitionTypes.SCRIPT); |
255 |
fInformationPresenter.setInformationProvider(javascriptInformationProvider, IHTMLPartitionTypes.SCRIPT); |
| 249 |
|
256 |
|
| 250 |
fInformationPresenter.setSizeConstraints(60, 10, true, true); |
257 |
fInformationPresenter.setSizeConstraints(60, 10, true, true); |
|
|
258 |
fInformationPresenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer)); |
| 251 |
} |
259 |
} |
| 252 |
|
260 |
|
| 253 |
return fInformationPresenter; |
261 |
return fInformationPresenter; |
|
Lines 302-309
Link Here
|
| 302 |
if (contentTypeId != null) |
310 |
if (contentTypeId != null) |
| 303 |
fReconciler.setValidatorStrategy(createValidatorStrategy(contentTypeId)); |
311 |
fReconciler.setValidatorStrategy(createValidatorStrategy(contentTypeId)); |
| 304 |
} |
312 |
} |
| 305 |
} |
313 |
} finally { |
| 306 |
finally { |
|
|
| 307 |
if (sModel != null) |
314 |
if (sModel != null) |
| 308 |
sModel.releaseFromRead(); |
315 |
sModel.releaseFromRead(); |
| 309 |
} |
316 |
} |
|
Lines 319-344
Link Here
|
| 319 |
if (hoverDescs[i].isEnabled() && EditorUtility.computeStateMask(hoverDescs[i].getModifierString()) == stateMask) { |
326 |
if (hoverDescs[i].isEnabled() && EditorUtility.computeStateMask(hoverDescs[i].getModifierString()) == stateMask) { |
| 320 |
String hoverType = hoverDescs[i].getId(); |
327 |
String hoverType = hoverDescs[i].getId(); |
| 321 |
if (TextHoverManager.COMBINATION_HOVER.equalsIgnoreCase(hoverType)) { |
328 |
if (TextHoverManager.COMBINATION_HOVER.equalsIgnoreCase(hoverType)) { |
| 322 |
// treat specially if it's JavaScript, HTML otherwise |
329 |
// check if script or html is needed |
| 323 |
if (contentType.equals(IHTMLPartitionTypes.SCRIPT)) { |
330 |
if (contentType == IHTMLPartitionTypes.SCRIPT) { |
| 324 |
hover = new JavaScriptBestMatchHoverProcessor(); |
331 |
hover = new JavaScriptBestMatchHoverProcessor(); |
| 325 |
} |
332 |
} else if (contentType == IHTMLPartitionTypes.HTML_DEFAULT) { |
| 326 |
else { |
|
|
| 327 |
hover = new HTMLBestMatchHoverProcessor(); |
333 |
hover = new HTMLBestMatchHoverProcessor(); |
| 328 |
} |
334 |
} |
| 329 |
} |
335 |
} else if (TextHoverManager.PROBLEM_HOVER.equalsIgnoreCase(hoverType)) { |
| 330 |
else if (TextHoverManager.PROBLEM_HOVER.equalsIgnoreCase(hoverType)) { |
|
|
| 331 |
hover = new ProblemAnnotationHoverProcessor(); |
336 |
hover = new ProblemAnnotationHoverProcessor(); |
| 332 |
} |
337 |
} else if (TextHoverManager.ANNOTATION_HOVER.equalsIgnoreCase(hoverType)) { |
| 333 |
else if (TextHoverManager.ANNOTATION_HOVER.equalsIgnoreCase(hoverType)) { |
|
|
| 334 |
hover = new AnnotationHoverProcessor(); |
338 |
hover = new AnnotationHoverProcessor(); |
| 335 |
} |
339 |
} else if (TextHoverManager.DOCUMENTATION_HOVER.equalsIgnoreCase(hoverType)) { |
| 336 |
else if (TextHoverManager.DOCUMENTATION_HOVER.equalsIgnoreCase(hoverType)) { |
340 |
// check if script or html is needed |
| 337 |
// treat specially if it's JavaScript, HTML otherwise |
341 |
if (contentType == IHTMLPartitionTypes.SCRIPT) { |
| 338 |
if (contentType.equals(IHTMLPartitionTypes.SCRIPT)) { |
|
|
| 339 |
hover = new JavaScriptTagInfoHoverProcessor(); |
342 |
hover = new JavaScriptTagInfoHoverProcessor(); |
| 340 |
} |
343 |
} else if (contentType == IHTMLPartitionTypes.HTML_DEFAULT) { |
| 341 |
else { |
|
|
| 342 |
hover = new HTMLTagInfoHoverProcessor(); |
344 |
hover = new HTMLTagInfoHoverProcessor(); |
| 343 |
} |
345 |
} |
| 344 |
} |
346 |
} |
|
Lines 358-361
Link Here
|
| 358 |
if (fInformationPresenter != null) |
360 |
if (fInformationPresenter != null) |
| 359 |
fInformationPresenter.uninstall(); |
361 |
fInformationPresenter.uninstall(); |
| 360 |
} |
362 |
} |
|
|
363 |
|
| 364 |
public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) { |
| 365 |
Vector vector = new Vector(); |
| 366 |
|
| 367 |
// prefix[0] is either '\t' or ' ' x tabWidth, depending on preference |
| 368 |
Preferences preferences = HTMLCorePlugin.getDefault().getPluginPreferences(); |
| 369 |
int indentationWidth = preferences.getInt(HTMLCorePreferenceNames.INDENTATION_SIZE); |
| 370 |
String indentCharPref = preferences.getString(HTMLCorePreferenceNames.INDENTATION_CHAR); |
| 371 |
boolean useSpaces = HTMLCorePreferenceNames.SPACE.equals(indentCharPref); |
| 372 |
|
| 373 |
for (int i = 0; i <= indentationWidth; i++) { |
| 374 |
StringBuffer prefix = new StringBuffer(); |
| 375 |
boolean appendTab = false; |
| 376 |
|
| 377 |
if (useSpaces) { |
| 378 |
for (int j = 0; j + i < indentationWidth; j++) |
| 379 |
prefix.append(' '); |
| 380 |
|
| 381 |
if (i != 0) |
| 382 |
appendTab = true; |
| 383 |
} else { |
| 384 |
for (int j = 0; j < i; j++) |
| 385 |
prefix.append(' '); |
| 386 |
|
| 387 |
if (i != indentationWidth) |
| 388 |
appendTab = true; |
| 389 |
} |
| 390 |
|
| 391 |
if (appendTab) { |
| 392 |
prefix.append('\t'); |
| 393 |
vector.add(prefix.toString()); |
| 394 |
// remove the tab so that indentation - tab is also an indent |
| 395 |
// prefix |
| 396 |
prefix.deleteCharAt(prefix.length() - 1); |
| 397 |
} |
| 398 |
vector.add(prefix.toString()); |
| 399 |
} |
| 400 |
|
| 401 |
vector.add(""); //$NON-NLS-1$ |
| 402 |
|
| 403 |
return (String[]) vector.toArray(new String[vector.size()]); |
| 404 |
} |
| 361 |
} |
405 |
} |