當前位置: 首頁>>代碼示例>>Java>>正文


Java GWTPartitions類代碼示例

本文整理匯總了Java中com.google.gwt.eclipse.core.editors.java.GWTPartitions的典型用法代碼示例。如果您正苦於以下問題:Java GWTPartitions類的具體用法?Java GWTPartitions怎麽用?Java GWTPartitions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GWTPartitions類屬於com.google.gwt.eclipse.core.editors.java包,在下文中一共展示了GWTPartitions類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getEnclosingJsniRegion

import com.google.gwt.eclipse.core.editors.java.GWTPartitions; //導入依賴的package包/類
public static ITypedRegion getEnclosingJsniRegion(ITextSelection selection,
    IDocument document) {
  try {
    ITypedRegion region = TextUtilities.getPartition(document,
        GWTPartitions.GWT_PARTITIONING, selection.getOffset(), false);

    if (region.getType().equals(GWTPartitions.JSNI_METHOD)) {
      int regionEnd = region.getOffset() + region.getLength();
      int selectionEnd = selection.getOffset() + selection.getLength();

      // JSNI region should entirely contain the selection
      if (region.getOffset() <= selection.getOffset()
          && regionEnd >= selectionEnd) {
        return region;
      }
    }
  } catch (BadLocationException e) {
    GWTPluginLog.logError(e);
  }

  return null;
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:23,代碼來源:JsniParser.java

示例2: format

import com.google.gwt.eclipse.core.editors.java.GWTPartitions; //導入依賴的package包/類
/**
 * Returns a text edit that formats the given document according to the given settings.
 *
 * @param document
 *            The document to format.
 * @param javaFormattingPrefs
 *            The formatting preferences for Java, used to determine the method level indentation.
 * @param javaScriptFormattingPrefs
 *            The formatting preferences for JavaScript. See org.eclipse.wst.jsdt.internal.formatter
 *            .DefaultCodeFormatterOptions and org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants
 * @param originalJsniMethods
 *            The original jsni methods to use if the formatter fails to format the method. The original jsni
 *            Strings must be in the same order that the jsni methods occur in the document. This is to work around
 *            the Java formatter blasting the jsni tabbing for the format-on-save action. May be null.
 * @return A text edit that when applied to the document, will format the jsni methods.
 */
@SuppressWarnings("unchecked")
public TextEdit format(IDocument document, Map javaFormattingPrefs, Map javaScriptFormattingPrefs,  Range range) {
	TextEdit combinedEdit = new MultiTextEdit();
	ITypedRegion[] regions = computePartitioning(document, range);

	// Format all JSNI blocks in the document
	int i = 0;
	for (ITypedRegion region : regions) {
		if (region.getType().equals(GWTPartitions.JSNI_METHOD)) {
			String originalJsniMethod = null;
			TextEdit edit = format(document, new TypedPosition(region), javaFormattingPrefs,
					javaScriptFormattingPrefs, originalJsniMethod);
			if (edit != null) {
				combinedEdit.addChild(edit);
			}
			i++;
		}
	}
	return combinedEdit;

}
 
開發者ID:krasa,項目名稱:EclipseCodeFormatter,代碼行數:38,代碼來源:JsniFormattingUtil.java

示例3: computePartitioning

import com.google.gwt.eclipse.core.editors.java.GWTPartitions; //導入依賴的package包/類
private static ITypedRegion[] computePartitioning(IDocument document, Range range) {
	ArrayList<ITypedRegion> iTypedRegions = new ArrayList<ITypedRegion>();
	String str = document.get();
	String prefix = "/*-";
	String postfix = "-*/";
	int startIndex = 0;
	int endIndex = 0;

	while (startIndex != -1) {
		startIndex = str.indexOf(prefix, startIndex);
		endIndex = str.indexOf(postfix, startIndex);

		if (startIndex != -1 && endIndex != -1) {
			endIndex = endIndex + 3;
			if (isInRange(range, startIndex, endIndex)) {
				iTypedRegions.add(new TypedRegion(startIndex, endIndex - startIndex, GWTPartitions.JSNI_METHOD));
			}
			startIndex += prefix.length();
		}
	}
	return iTypedRegions.toArray(new ITypedRegion[iTypedRegions.size()]);

}
 
開發者ID:krasa,項目名稱:EclipseCodeFormatter,代碼行數:24,代碼來源:JsniFormattingUtil.java

示例4: format

import com.google.gwt.eclipse.core.editors.java.GWTPartitions; //導入依賴的package包/類
private TextEdit format(IDocument document, Range range) {
	TextEdit combinedEdit = new MultiTextEdit();
	ITypedRegion[] regions = computePartitioning(document, range);

	// Format all JSNI blocks in the document
	int i = 0;
	for (ITypedRegion region : regions) {
		if (region.getType().equals(GWTPartitions.JSNI_METHOD)) {
			TextEdit edit = format(document, new TypedPosition(region));
			if (edit != null) {
				combinedEdit.addChild(edit);
			}
			i++;
		}
	}
	return combinedEdit;

}
 
開發者ID:krasa,項目名稱:EclipseCodeFormatter,代碼行數:19,代碼來源:JSCommentsFormatterProcessor.java

示例5: computePartitioning

import com.google.gwt.eclipse.core.editors.java.GWTPartitions; //導入依賴的package包/類
private static ITypedRegion[] computePartitioning(IDocument document, Range range) {
	ArrayList<ITypedRegion> iTypedRegions = new ArrayList<ITypedRegion>();
	String str = document.get();
	String prefix = "/**";
	String postfix = "*/";
	int startIndex = 0;
	int endIndex = 0;

	while (startIndex != -1) {
		startIndex = str.indexOf(prefix, startIndex);
		endIndex = str.indexOf(postfix, startIndex);

		if (startIndex != -1 && endIndex != -1) {
			endIndex = endIndex + 3;
			if (isInRange(range, startIndex, endIndex)) {
				iTypedRegions.add(new TypedRegion(startIndex, endIndex - startIndex, GWTPartitions.JSNI_METHOD));
			}
			startIndex += prefix.length();
		}
	}
	return iTypedRegions.toArray(new ITypedRegion[iTypedRegions.size()]);

}
 
開發者ID:krasa,項目名稱:EclipseCodeFormatter,代碼行數:24,代碼來源:JSCommentsFormatterProcessor.java

示例6: testGetEnclosingJsniRegionSelectionInsideJsni

import com.google.gwt.eclipse.core.editors.java.GWTPartitions; //導入依賴的package包/類
public void testGetEnclosingJsniRegionSelectionInsideJsni() {
  IRegion selRegion = RegionConverter.convertWindowsRegion(169, 3, testClass.getContents());
  ITextSelection sel = new TextSelection(selRegion.getOffset(), selRegion.getLength());
  ITypedRegion jsniRegion = JsniParser.getEnclosingJsniRegion(sel, getTestClassDocument());
  assertNotNull(jsniRegion);
  assertEquals(GWTPartitions.JSNI_METHOD, jsniRegion.getType());

  IRegion expectedJsniRegion = RegionConverter.convertWindowsRegion(121, 234, testClass.getContents());
  assertEquals(expectedJsniRegion.getOffset(), jsniRegion.getOffset());
  assertEquals(expectedJsniRegion.getLength(), jsniRegion.getLength());
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:12,代碼來源:JsniParserTest.java

示例7: testGetEnclosingJsniRegionSelectionIsJsni

import com.google.gwt.eclipse.core.editors.java.GWTPartitions; //導入依賴的package包/類
public void testGetEnclosingJsniRegionSelectionIsJsni() {
  IRegion selRegion = RegionConverter.convertWindowsRegion(121, 234, testClass.getContents());
  ITextSelection sel = new TextSelection(selRegion.getOffset(), selRegion.getLength());
  ITypedRegion jsniRegion = JsniParser.getEnclosingJsniRegion(sel, getTestClassDocument());
  assertNotNull(jsniRegion);
  assertEquals(GWTPartitions.JSNI_METHOD, jsniRegion.getType());
  IRegion expectedJsniRegion = RegionConverter.convertWindowsRegion(121, 234, testClass.getContents());
  assertEquals(expectedJsniRegion.getOffset(), jsniRegion.getOffset());
  assertEquals(expectedJsniRegion.getLength(), jsniRegion.getLength());
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:11,代碼來源:JsniParserTest.java

示例8: run

import com.google.gwt.eclipse.core.editors.java.GWTPartitions; //導入依賴的package包/類
public void run(IAction action) {
  if (targetEditor == null) {
    GWTPluginLog.logWarning("targetEditor is null");
    return;
  }

  IEditorInput editorInput = targetEditor.getEditorInput();
  IResource resource = (IResource) editorInput.getAdapter(IResource.class);
  ITextEditor javaEditor = (ITextEditor) targetEditor;
  ITextSelection sel = (ITextSelection) javaEditor.getSelectionProvider().getSelection();
  IDocument document = javaEditor.getDocumentProvider().getDocument(
      javaEditor.getEditorInput());

  IDocumentExtension3 document3 = (IDocumentExtension3) document;
  IDocumentPartitioner gwtPartitioner = document3.getDocumentPartitioner(GWTPartitions.GWT_PARTITIONING);

  String[] partitionings = document3.getPartitionings();
  String partitioning = (gwtPartitioner != null
      ? GWTPartitions.GWT_PARTITIONING : IJavaPartitions.JAVA_PARTITIONING);

  ITypedRegion[] types;
  try {
    types = TextUtilities.computePartitioning(document, partitioning,
        sel.getOffset(), sel.getLength(), false);
  } catch (BadLocationException e) {
    GWTPluginLog.logError(e);
    return;
  }

  String msg = "File: " + resource.getName();

  msg += "\nPartitionings: ";
  for (String part : partitionings) {
    msg += "\n" + part;
  }

  msg += "\n\nContent types: ";
  for (ITypedRegion type : types) {
    msg += "\n" + type.getType();
  }

  msg += "\n\nSelection range: (offset = " + sel.getOffset() + ", length = "
      + sel.getLength() + ")";

  MessageDialog.openInformation(targetEditor.getSite().getShell(),
      "Selection Info", msg);
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:48,代碼來源:EditorAction.java


注:本文中的com.google.gwt.eclipse.core.editors.java.GWTPartitions類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。