-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement themeAssociation + preview with theme/grammar. See
#32 Signed-off-by: angelozerr <[email protected]>
- Loading branch information
1 parent
c6c4805
commit eaf09cc
Showing
24 changed files
with
875 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,35 +12,42 @@ | |
* Contributors: | ||
* - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license | ||
* - Angelo Zerr <[email protected]> - translation and adaptation to Java | ||
*/ | ||
package org.eclipse.tm4e.core.grammar; | ||
|
||
/** | ||
* TextMate grammar API. | ||
* | ||
* @see https://github.com/Microsoft/vscode-textmate/blob/master/src/main.ts | ||
* | ||
*/ | ||
public interface IGrammar { | ||
|
||
/** | ||
* Tokenize `lineText`. | ||
* | ||
* @param lineText | ||
* the line text to tokenize. | ||
* @return the result of the tokenization. | ||
*/ | ||
ITokenizeLineResult tokenizeLine(String lineText); | ||
|
||
/** | ||
* Tokenize `lineText` using previous line state `prevState`. | ||
* | ||
* @param lineText | ||
* the line text to tokenize. | ||
* @param prevState | ||
* previous line state. | ||
* @return the result of the tokenization. | ||
*/ | ||
ITokenizeLineResult tokenizeLine(String lineText, StackElement prevState); | ||
|
||
} | ||
*/ | ||
package org.eclipse.tm4e.core.grammar; | ||
|
||
/** | ||
* TextMate grammar API. | ||
* | ||
* @see https://github.com/Microsoft/vscode-textmate/blob/master/src/main.ts | ||
* | ||
*/ | ||
public interface IGrammar { | ||
|
||
/** | ||
* Returns the scope name of the grammar. | ||
* | ||
* @return the scope name of the grammar. | ||
*/ | ||
String getScopeName(); | ||
|
||
/** | ||
* Tokenize `lineText`. | ||
* | ||
* @param lineText | ||
* the line text to tokenize. | ||
* @return the result of the tokenization. | ||
*/ | ||
ITokenizeLineResult tokenizeLine(String lineText); | ||
|
||
/** | ||
* Tokenize `lineText` using previous line state `prevState`. | ||
* | ||
* @param lineText | ||
* the line text to tokenize. | ||
* @param prevState | ||
* previous line state. | ||
* @return the result of the tokenization. | ||
*/ | ||
ITokenizeLineResult tokenizeLine(String lineText, StackElement prevState); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...e.ui/src/main/java/org/eclipse/tm4e/ui/internal/preferences/ContentTypeLabelProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright (c) 2015-2017 Angelo ZERR. | ||
* 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: | ||
* Angelo Zerr <[email protected]> - initial API and implementation | ||
*/ | ||
package org.eclipse.tm4e.ui.internal.preferences; | ||
|
||
import org.eclipse.core.runtime.Platform; | ||
import org.eclipse.core.runtime.content.IContentType; | ||
import org.eclipse.jface.viewers.ITableLabelProvider; | ||
import org.eclipse.jface.viewers.LabelProvider; | ||
import org.eclipse.swt.graphics.Image; | ||
|
||
/** | ||
* Label provider for {@link IContentType}. | ||
*/ | ||
class ContentTypeLabelProvider extends LabelProvider implements ITableLabelProvider { | ||
|
||
@Override | ||
public Image getColumnImage(Object element, int columnIndex) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getText(Object element) { | ||
return getColumnText(element, 0); | ||
} | ||
|
||
@Override | ||
public String getColumnText(Object element, int columnIndex) { | ||
String contentTypeId = (String) element; | ||
switch (columnIndex) { | ||
case 0: | ||
IContentType contentType = Platform.getContentTypeManager().getContentType(contentTypeId); | ||
if (contentType == null) { | ||
return contentTypeId; | ||
} | ||
return contentType.getName() + " (" + contentType.getId() + ")"; | ||
default: | ||
return ""; //$NON-NLS-1$ | ||
} | ||
} | ||
} |
Oops, something went wrong.